/// 状态码
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Status {
    /// 响应
    Response = 0x00,
    /// 请求
    Request = 0x01,
    /// 通知
    Notice = 0x02,
    /// 当前设备未登录
    NotLogin = 0x11,
    /// 设备登录码错误
    LoginCodeErr = 0x12,
    /// 当前设备已登录
    HadLogin = 0x13,
    /// 超时断开
    Timeout = 0x14,
    /// 时间戳错误
    SnExpire = 0x15,
    /// 产品码错误
    ProductCodeErr = 0x16,
    /// 目标设备未登录
    TargetNotLogin = 0x21,
    /// 设备操作码错误
    OpCodeErr = 0x22,
    /// 目标变量不存在
    NoVar = 0x23,
    /// 仅自己可以设置实际值
    NeedSelf = 0x24,
    /// 不能订阅自己的变量
    SubSelf = 0x25,
    /// 实际值不能为空
    Null = 0x26,
    /// 绑定模式超时
    BindTimeout = 0x31,
    /// 用户绑定失败
    BindErr = 0x32,
    /// 无效状态
    Unknown,
}
impl Default for Status {
    fn default() -> Self {
        Status::Unknown
    }
}
impl From<u8> for Status {
    fn from(status: u8) -> Self {
        match status {
            x if x == Status::Response as u8 => Status::Response,
            x if x == Status::Request as u8 => Status::Request,
            x if x == Status::Notice as u8 => Status::Notice,
            x if x == Status::NotLogin as u8 => Status::NotLogin,
            x if x == Status::LoginCodeErr as u8 => Status::LoginCodeErr,
            x if x == Status::HadLogin as u8 => Status::HadLogin,
            x if x == Status::Timeout as u8 => Status::Timeout,
            x if x == Status::SnExpire as u8 => Status::SnExpire,
            x if x == Status::ProductCodeErr as u8 => Status::ProductCodeErr,
            x if x == Status::TargetNotLogin as u8 => Status::TargetNotLogin,
            x if x == Status::OpCodeErr as u8 => Status::OpCodeErr,
            x if x == Status::NoVar as u8 => Status::NoVar,
            x if x == Status::NeedSelf as u8 => Status::NeedSelf,
            x if x == Status::SubSelf as u8 => Status::SubSelf,
            x if x == Status::Null as u8 => Status::Null,
            x if x == Status::BindTimeout as u8 => Status::BindTimeout,
            x if x == Status::BindErr as u8 => Status::BindErr,
            _ => Status::Unknown,
        }
    }
}
